//
//  UIApplication+Info.m
//  ITC_iOS
//
//  Created by Benz.L on 04/09/2018.
//  Copyright © 2018 Benz.L. All rights reserved.
//

#import "UIApplication+Info.h"

@implementation UIApplication(Info)

+ (NSDictionary *)info {
    return [[NSBundle mainBundle] infoDictionary];
}
+ (NSString *)appName {
     return self.info[@"CFBundleDisplayName"];
}
+ (NSString *)appVersion {
    return self.info[@"CFBundleShortVersionString"];
}
+ (NSString *)buildVersion {
    return self.info[@"CFBundleVersionString"];
}
+ (NSArray<NSString *> *)appIcons {
    return [self.info valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"];
}
+ (void)jumpToUpdate:(NSString *)AppId
{
    NSString *url = [NSString stringWithFormat:@"http://itunes.apple.com/cn/app/id%@?mt=8", AppId];
    if (@available(iOS 10.0, *)) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {
        }];
    }
    else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    }
}

+ (void)jumpToScore:(NSString *)AppId
{
    NSString *url = [@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=" stringByAppendingString:AppId];
    if (@available(iOS 10.0, *)) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {
        }];
    }
    else {    
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    }
}
@end
